class Solution:
    def topKFrequent(self, nums: List[int], k: int) -> List[int]:
        set01 = set(nums)
        nums_dict = {item: nums.count(item) for item in set01}
        return [v for v, c in sorted(nums_dict.items(), key=lambda x: x[1], reverse=True)][:k]
